package com.yanqu.road.entity.activity.harps;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.suitang.config.*;
import com.yanqu.road.entity.activity.suitang.enums.eSuiTangStage;
import com.yanqu.road.entity.activity.suitang.enums.eSuiTangWarType;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class HarpsConfigSync {
    // 活动ID
    private int activityId;

    // 活动信息
    private ActivityInfo activityInfo;

    // 活动配置信息
    private Map<String, ActivityConfig> activityConfigMap;

    // buff 配置
    private Map<Integer, HarpsMountConfig> mountConfigMap;

    // param 配置
    private HarpsParamConfig paramConfig = new HarpsParamConfig();

    // 剩余可选次数无上限
    private final int remainChooseNumNoLimit = -1;

    // 自选层无解锁次数
    private final int chooseFloorNoUnlockNum = 0;

    // 顶层为第四层
    private final int highestFloor = 4;

    // 初始演奏消耗
    private final int initPlayReduce = 1;

    // 顶层奖励
    private Map<String, String> highestRewardConfig = new ConcurrentHashMap<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public Map<String, ActivityConfig> getActivityConfigMap() {
        return activityConfigMap;
    }

    public void setActivityConfigMap(Map<String, ActivityConfig> activityConfigMap) {
        this.activityConfigMap = activityConfigMap;
    }

    public Map<Integer, HarpsMountConfig> getMountConfigMap() {
        return mountConfigMap;
    }

    public void setMountConfigMap(Map<Integer, HarpsMountConfig> mountConfigMap) {
        this.mountConfigMap = mountConfigMap;
    }

    public HarpsParamConfig getParamConfig() {
        return paramConfig;
    }

    public void setParamConfig(HarpsParamConfig paramConfig) {
        this.paramConfig = paramConfig;
    }

    /*
     * 获取指定层的奖励配置信息
     */
    public List<HarpsMountConfig> getMountConfigByFloor(int floor) {
        List<HarpsMountConfig> ret = new ArrayList<>();
        for (HarpsMountConfig config : mountConfigMap.values()) {
            if (config.getFloor() == floor) {
                ret.add(config);
            }
        }
        return ret;
    }

    /*
     * 初始化顶层奖励
     */
    public void initHighestReward() {
        for (HarpsMountConfig mountConfig : mountConfigMap.values()) {
            if (mountConfig.getFloor() != highestFloor) {
                continue;
            }
            String award = mountConfig.getAward();
            List<String> awards = StringUtils.stringToStringList(award, "\\|");
            if (awards.isEmpty()) {
                continue;
            }
            for (String s : awards) {
                List<String> strs = StringUtils.stringToStringList(s, "#");
                if (strs.isEmpty()) {
                    continue;
                }
                List<String> strRewards = StringUtils.stringToStringList(strs.get(1), ",");
                if (strRewards.isEmpty()) {
                    continue;
                }
                highestRewardConfig.put(mountConfig.getPrizeId() + "_" + strs.get(0), strRewards.get(0));
            }
        }
    }

    /*
     * 获取顶层对应奖励
     */
    public String getHighestReward(int id, int no) {
        return highestRewardConfig.get(id + "_" + no);
    }

    public int getRemainChooseNumNoLimit() {
        return remainChooseNumNoLimit;
    }

    public int getChooseFloorNoUnlockNum() {
        return chooseFloorNoUnlockNum;
    }

    public int getHighestFloor() {
        return highestFloor;
    }

    public int getInitPlayReduce() {
        return initPlayReduce;
    }
}
